<?php

class Search_model extends MY_Model{
    
    public function records($lang,$keyword){
	$sql = "select
		    id,
		    type,
		    title,
		    content,
		    labels,
		    created_at
		from 
		(
		    select
			id,created_at,
			'news' as type,
			title_{$lang} as title,
			content_{$lang} as content,
			labels_{$lang} as labels
		    from alsa_news
		    union
		    select 
			id,created_at,
			'project' as type,
			name_{$lang} as title,
			description_{$lang} as content,
			labels_{$lang} as labels
		    from alsa_project
		) p
		where labels like '%{$keyword}%';";

	$query = $this->db->query($sql);
	
	return $query->result();
    }
    
}